﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SilentVoice.Models;
using SilentVoice.ServiceObjects;
using SilentVoice.Business;

namespace SilentVoice.Service.Controllers
{
    [Authorize]
    public class AccountsController : ApiController
    {
        private Manager manager;

        public AccountsController()
        {
            manager = new Manager();
        }
        
        // GET api/accounts
        public IEnumerable<ServiceAccount> Get()
        {
            throw new NotImplementedException();
        }
        //TODO: test
        // GET api/accounts/5
        public ServiceAccount Get(int id)
        {
            return new ServiceAccount(manager.GetAccount(id));
        }

        // POST api/accounts
        public void Post([FromBody]string value)
        {
        }

        // PUT api/accounts/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/accounts/5
        public void Delete(int id)
        {
        }

        //TODO: test
        public IEnumerable<ServiceUser> Users(int id)
        {
            return manager.GetAccountUsers(id).Select(user => new ServiceUser(user));
        }
    }
}
